home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac: Not for Sale / Another.not.for.sale (Australia).iso / hold me in your arms / clarinet / newsclip < prev    next >
Text File  |  1994-09-11  |  14KB  |  330 lines

  1.    
  2.                      NEWSCLIP(TM) NEWS FILTERING LANGUAGE
  3.                                        
  4.    Turn USENET into the network you want it to be.
  5.    
  6.    USENET is an information explosion. If you're on it, you know the
  7.    problem is not finding stuff to read, it's finding the *right* stuff
  8.    to read in a vast sea of information. Sometimes it's like looking for
  9.    a needle in a haystack.
  10.    
  11.    To help, we developed NewsClip, a programming language that lets you
  12.    control what you will read and not read. Current tools only let you
  13.    control what's presented to you through newsgroup selection and the
  14.    elimination of messages that match certain pattern strings. What's
  15.    worse, they use up your time doing it.
  16.    
  17.    With NewsClip, you can control what is shown to you as finely as you
  18.    desire, with all the tools of a powerful programming language at your
  19.    disposal. The programs you write are compiled, so they filter you news
  20.    for you quickly -- often without any noticeable delay.
  21.    
  22.    Your NewsClip programs accept, reject or weight articles based on
  23.    C-like expressions you write to describe what you want or don't want
  24.    to see. You might reject all articles in "rec.humor" that are
  25.    cross-posted to "talk.bizarre", unless they are posted by a user at
  26.    your own site with:
  27.    
  28.  
  29.         reject if is rec.humor && is talk.bizarre &&
  30.                         domain(from) != my_domain;
  31.  
  32.    What you can do is limitless.
  33.    
  34.    Your compiled programs can work in several ways. With a few small
  35.    alterations to your newsreader (patches are provided for the RN
  36.    reader), your program will filter news as you read it, usually with no
  37.    delay. You simply see the articles you wish to see. The modified RN
  38.    reader can also send commands to the filter program to interactively
  39.    control filtering.
  40.    
  41.    You can also arrange to filter news in the background, or at night.
  42.    Your filter program will read your news subscription file, scan all
  43.    unread articles, and pre-mark undesired articles as read, so that you
  44.    never see them. This works with any system that uses a .newsrc file.
  45.    
  46.    NewsClip programs can also filter a list of article filenames, such as
  47.    a list of articles to be fed to another system. This way you can fine
  48.    tune the feeding of articles to other systems as precisely as you
  49.    desire. You can also arrange to feed other sites by creating a newsrc
  50.    for the destination site, so that you don't need the "sys" file.
  51.    
  52.    An important thing to remember is that with NewsClip, you are not
  53.    limited to describing what you don't want to see, as is the case with
  54.    RN KILL files. You can also request what you want to see, and
  55.    eliminate all the rest. Or you can combine the two, or vary the rules
  56.    from group to group or message to message.
  57.    
  58.    Here are some of the things you can do:
  59.      * Eliminate or request followup trees. You can kill off or follow a
  60.        topic or subtopic based on the subject or the "Message-id:" and
  61.        "References:" lines.
  62.      * Control crossposting. You can request to only see articles
  63.        crossposted to multiple groups, or reject or accept articles based
  64.        on what groups they are crossposted to. You can even reject any
  65.        article crossposted to too many groups.
  66.      * Eliminate a user, group of users or even a site. You can arrange
  67.        not only to not see the postings of certain users, but to not even
  68.        see the followups to those postings. You can thus eliminate
  69.        unwanted users or classes of postings from *your* net -- you'll
  70.        never even know they're there.
  71.      * Keyword match articles based on the presence of patterns in header
  72.        items or various sections of the article text. You can ask to see
  73.        articles that mention "unix" but don't mention "ms-dos."
  74.      * Accept your own articles and give priority to followups to your
  75.        own articles.
  76.      * Accept articles posted only to a local distribution, even if
  77.        they're in a netwide group. As shown above, you can arrange to
  78.        accept articles from people on your own site, even if you might
  79.        not normally see them.
  80.      * Reject articles with signatures that are too long, or which
  81.        contain too much included text.
  82.      * Accept only original (non-followup) articles and followups to
  83.        those articles that you have explicitly decided to track. (It's
  84.        like having a USENET 1/10th the volume of the current one.)
  85.        
  86.    In other words, with NewsClip, you can turn USENET into the network
  87.    you want it to be. Anything that a computer program can figure out
  88.    about an article can be used to decide whether you will see the
  89.    article or not.
  90.    
  91. How NewsClip Works
  92.  
  93.    The NewsClip compiler translates your filter program into a C program.
  94.    This C program is compiled by your local C compiler and linked with
  95.    the NewsClip library. That library processes articles and handles the
  96.    interface to news readers and the real world.
  97.    
  98.    The goal of your program is to decide whether to accept or reject an
  99.    article. This can be done piece by piece (reject if this, accept if
  100.    that) or it can be done by giving a score to the article based on
  101.    conditional expressions. You can add points to articles with things
  102.    you like, and take them away from articles with things you don't like.
  103.    At the end, if the score is still positive, you see the article.
  104.    
  105.  
  106.         if( lines > 200 )
  107.                 adjust 200-lines;
  108.  
  109.    The language is C-like, but has data types that represent the kind of
  110.    things found in articles and article headers. Perhaps most important
  111.    is the "database" type, which is really an integer array that you can
  112.    index with string values. You use databases to keep track of users,
  113.    message-ids, patterns, subjects and other key items you might look for
  114.    in articles.
  115.    
  116.    Your NewsClip program can update databases on its own. If an article
  117.    comes in that you really hate, you can automatically put its
  118.    message-id in a database that marks messages you don't want to see
  119.    followups of. To you, it's as if the message was never posted.
  120.    
  121.  
  122.         if( from in badusers ) {
  123.                 badmessages[message_id] = true;
  124.                 reject;
  125.                 }
  126.  
  127.    Databases can be stored on disk, and a special feature allows you to
  128.    "expire" database records that have not been accessed in a while.
  129.    
  130.    Your filter program can run in parallel with a newsreader like RN. We
  131.    have developed a general protocol that any newsreader can use to talk
  132.    to a filter program. This includes the ability to send commands to the
  133.    filter program, such as "kill all articles with this subject."
  134.    
  135.    To examine an article, you mainly work with the header. There are
  136.    predefined external variables for all the major headers, or you can
  137.    custom-declare your own:
  138.    
  139.  
  140.         header string array keys : "keywords", ",";
  141.  
  142.    (This gets you an array variable called "keys" whose elements will be
  143.    the comma-delimited keywords from the "Keywords:" header line.)
  144.    
  145.    You can define your own procedures and functions in the NewsClip
  146.    language, or even import C functions from the C libraries or your own
  147.    C programs.
  148.    
  149.  
  150.         extern int strlen( string );
  151.  
  152.    NewsClip contains a special "distribution" feature that lets you check
  153.    the distribution of an article and estimate how many machines it will
  154.    go to. You can thus accept or reject articles based on their audience,
  155.    as well as their newsgroup.
  156.    
  157.    You can split up articles into various regions when doing pattern
  158.    matching in the body. The signature, main text, non-included text and
  159.    whole body are all regions that you can examine independently.
  160.    
  161.  
  162. reject if line_count(signature) > 20
  163.         || newtext has "ron.*reagan";
  164.  
  165. How to Get NewsClip
  166.  
  167.    NewsClip runs on most Unix systems, including Xenix/286. It requires a
  168.    C compiler and a standard news directory structure. It can also be
  169.    used in conjunction with "RRN."
  170.    
  171.    NewsClip is a product of Looking Glass Software Limited, marketed by
  172.    ClariNet Communications Corp. It is available free to most ClariNews
  173.    subscribers. ClariNews provides electronic publications, including
  174.    live newswire news, computer industry news and other electronic
  175.    services. The newswire can be filtered well by NewsClip programs.
  176.    
  177.    NewsClip is also available free for non-commercial use to
  178.    non-subscribers. You can get Newsclip via ftp.
  179.    
  180. Sample Program
  181.  
  182.  
  183. /* Sample NEWSCLIP program that shows what you can do */
  184. /* This program is far more complex than a typical system, which
  185.    would usually be quite short. */
  186.  
  187. /* Please folks, this is not the newsclip program that I use, and I
  188.    don't advocate all the different filtering things here.  I am
  189.    just using them as examples of how to do certain things net people
  190.    have suggested they wanted done. */
  191.  
  192.         /* You can include pre-defined header lines */
  193.         extern userid From;                     /* the From: line */
  194.         extern newsgroup array newsgroups;      /* the Newsgroups: line */
  195.         extern int distribution_level;          /* max distr of article */
  196.         extern string array references;         /* parent articles */
  197.         extern string Subject;                  /* subject line */
  198.         extern int followup;                    /* is it a followup? */
  199.         extern int lines;                       /* header variable */
  200.         /* or define your own header lines */
  201.         header string mess_id : "message-id";
  202.         /* declare variables */
  203.         int counter;
  204.         /* some databases I will look things up in */
  205.         database badmessages;                   /* message-ids I don't want
  206.                                                 to see followsup to */
  207.         database hated_users;                   /* users I don't want to
  208.                                                    see articles from */
  209.         database my_articles;                   /* message-ids that I
  210.                                                 want to see ALL followups to */
  211.         /* declare external C functions from the Newsclip library or your
  212.            own C libraries */
  213.         extern int strlen( string );
  214.  
  215.         /* you can define procedures and functions */
  216.  
  217. int
  218. nice_group( newsgroup n )
  219. {
  220.         extern string left( string, int );
  221.         /* you like all sci newsgroups and rec.humor.funny */
  222.         return n == #rec.humor.funny || left(n,1) == "sci";
  223. }
  224.  
  225. procedure
  226. INIT() {
  227.         extern procedure set_include_prefix(string);
  228.         /* this code gets run when the program starts */
  229.         set_include_prefix( "[:>]" );
  230.         hated_users = read_database( "~./hatedusers" );
  231.         my_articles = read_database( "~./myarticles" );
  232. }
  233.  
  234. procedure
  235. STARTGROUP() {
  236.         /* This gets called when we begin to scan a new newsgroup */
  237.         /* read in the database of bad message-ids for this group */
  238.         badmessages = read_database( "~./kill/~n/killdb" );
  239. }
  240.  
  241. procedure
  242. ENDGROUP() {
  243.         /* this gets called to end the newsgroup */
  244.         extern datetime time_now;
  245.  
  246.         /* write out the bad message database, delete all entries that
  247.           are older than one month */
  248.         write_database( badmessages, "~./kill/~n/killdb", time_now - month );
  249.         free_database( badmessages );
  250. }
  251.  
  252.         /* here is the main part.  The code that is executed for every
  253.            article to accept or reject it */
  254.  
  255. procedure
  256. ARTICLE() {
  257.         newsgroup n;
  258.         extern string domain( string );
  259.         extern string right( string, int );
  260.         extern int dlevel( newsgroup );
  261.         extern string my_domain;
  262.         extern string my_mail_address;
  263.  
  264.         /* show me everything written by people at my own site */
  265.         if( domain(From) == my_domain ) {
  266.                 /* Note my own articles in a database of good ones */
  267.                 if( From == my_mail_address )
  268.                         my_articles[mess_id] = true;
  269.                 accept;
  270.                 }
  271.          else if( domain(From) == "hated.domain.com" )
  272.                 reject;         /* never show me anything from THAT site */
  273.         /* also show me anything posted only for citywide distribution */
  274.         accept if distribution_level  6;        /* I hate crossposting */
  275.  
  276.         /* See if it's a followup to one of MY messages */
  277.         accept if References in my_articles;
  278.  
  279.         /* See if any of the messages this is a followup of are in
  280.            our database of bad messages.  If so, reject it */
  281.         reject if References in badmessages;
  282.  
  283.         /* and of course, kill the bad guys */
  284.         reject if From in hated_users;
  285.  
  286.         /* Now do the newsgroup specific code */
  287.         for( n in newsgroups ) switch( n ) {
  288.                 case #rec.humor:
  289.                         /* adjust the score of messages that are crossposted
  290.                                 to groups you don't like */
  291.                         if( is talk.bizarre || is alt.flame )
  292.                                 adjust -10;
  293.                         /* but I like local humour */
  294.                         accept if distribution_level  7 )
  295.                                 reject;
  296.                         break;
  297.                 case #talk.politics.theory:
  298.                         /* search for libertarian only in non-included text */
  299.                         if( newtext has "libertarian" || newtext has "ncp" )
  300.                                 accept;
  301.                          else
  302.                                 reject;
  303.                 case #comp.risks:
  304.                 case #rec.arts.sf-lovers:
  305.                         /* my favourite groups */
  306.                         adjust 20;
  307.                         break;
  308.                 default:
  309.                         if( nice_group(n) )
  310.                                 adjust 15;
  311.                         break;
  312.  
  313.                 }
  314.         if( is alt.flame )
  315.                 adjust -5;              /* I would rather not see these */
  316.         /* default is a score of 1, which means accept */
  317.         /* here at the end, we accept if the score is greater than 0, or
  318.            if there was an explicit accept, of course */
  319.  
  320. }
  321.  
  322. procedure
  323. TERMINATE() {
  324.         extern datetime time_now;
  325.         /* The program is done.  Write out global databases */
  326.         write_database( my_articles, "~./my_articles", time_now - 3 * week );
  327. }
  328.  
  329.    July 17, 1994
  330.